<!-- Front page for Marketplace -->
<?php 
 session_start();
?>

<!DOCTYPE HTML>
<html>
  <head>
    <title>Movie DB</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="datepicker/css/datepicker.css" rel="stylesheet">
    <script src="datepicker/js/bootstrap-datepicker.js"> </script>
    <script src="script/jquery-1.9.1.min.js"> </script>
    <script src="bootstrap/js/bootstrap.min.js"> </script>
    <script src="script/jquery.validate.js"> </script>

    

    <style type="text/css">
      .header {
        margin-top:20px;
      }

      #front-search-form {
        padding-top: 10px;
        border-style: solid;
        border-width: 2px;
      }
     
    </style>
    <script>
      function loadLoginModal() {
        $("#loginModal").modal();
      }

      function loadSignupModal(){
        $("#signupModal").modal();
      }

      $(document).ready(function() {
       
      });

      

    </script>
  </head>
  <body>
    <div class="container">
      <!--marketplace banner photo -->
      <div class="header row-fluid">
        <div class="span7">
          <h1>Online Movie Rental System
            <small> CS2102 </small>
          </h1>
        </div>
        <div clas="span5">
        
        

          <div class=" pull-right" style="margin-top:20px;">
              <a class="btn btn-success" onclick="loadLoginModal(); return false;" style="<?php if($_SESSION['check'] == true) echo 'display: none'; ?>"> Log in </a>  
              <a class="btn" onclick="loadSignupModal(); return false;" style="<?php if($_SESSION['check'] == true) echo 'display: none'; ?>"> register </a> 
              <a href="#"><?php if(isset($_SESSION['check']) && $_SESSION['check'] == true) echo "User: "."$_SESSION[name]"; ?></a>
              <a class="btn" href="logout.php" style="<?php if (!isset($_SESSION['check']) || $_SESSION['check'] != true) echo 'display: none'; ?>"> log out </a> 
          </div>

          
        </div>
      </div>

      <div class="navbar">
        <div class="navbar-inner">
          <a class="brand" href="#">MOVIES!</a>
          <ul class="nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">My bookings</a></li>
            <li><a href="#">All Movies</a></li>
          </ul>
        </div>
      </div>


      <!-- front search form -->

      <div class="row-fluid">
        <div class="span5 front-search">
            <form class="form-horizontal" id="front-search-form">
              <div class="control-group">
                <label class="control-label" for="title">Title</label>
                <div class="controls">
                  <input type="text" id="title" placeholder="Movie Title">
                </div>
              </div>
          <div class="control-group">
            <label class="control-label" for="name">name</label>
            <div class="controls">
              <input type="text" id="name" required name="name" placeholder="movie name?">
            </div>
          </div>
           <div class="control-group">
             <label class="control-label">Genre</label>
             <div class="controls">
              <?php 
                 $con = mysqli_connect("localhost","root","","movie");
                if(!$con)
                  die("Could not connect" . mysql_error());
                    $result = mysqli_query($con,"SELECT name FROM genre");
                    if ($result) {
                      while($row = mysqli_fetch_array($result)) {
                        $name = $row['name'];
                        echo "<label class='checkbox inline'>";
                        echo "<input type='checkbox' id='".$name."' value='".$name."'>".$name;
                        echo "</label>";
                      }
                    }
                ?>
            </div>
          </div>
            </form>
        </div>


        <!-- Top Records -->
        <div class="span7 front-top">
        </div>
      </div>
     
    </div>


    <!-- sign up form modal -->
    <div class="modal hide fade" id="signupModal">
       <form action="register.php" method="post" class="form-horizontal" id="signup-form" style="margin-bottom:0px">
     
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>Sign up</h3>
      </div>
      <div class="modal-body">
              <div class="control-group">
                <label class="control-label" for="name" >Username</label>
                <div class="controls">
                  <input type="text" id="name" name="name"required placeholder="your username?">
                </div>
              </div>

              <div class="control-group">
                <label class="control-label" for="email">email</label>
                <div class="controls">
                  <input type="email" id="email" required name="email" placeholder="your email address?">
                </div>
              </div>

              <div class="control-group">
                <label class="control-label" for="address">address</label>
                <div class="controls">
                  <input type="text" id="address" name="address" required placeholder="your address?">
                </div>
              </div>

              <div class="control-group">
                <label class="control-label" for="telephone">telephone</label>
                <div class="controls">
                  <input type="text" id="telephone" required name="telephone" placeholder="your telephone number?">
                </div>
              </div>

              <div class="control-group">
                <label class="control-label" for="inputPassword">Password</label>
                <div class="controls">
                  <input id="inputPassword" required name="password" type="password"  placeholder="Password">
                </div>
              </div>
      </div>
 
      <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <button type="submit" class="btn btn-primary">Register</button>
      </div>
 
     </form>
    </div>


    <!-- login modal -->
    <div class="modal hide fade" id="loginModal">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>Log in</h3>
      </div>
       <form action="login.php" method="post" class="form-horizontal" id="login-form" style="margin-bottom:0px">
      <div class="modal-body">
          <div class="control-group">
            <label class="control-label" for="email">email</label>
            <div class="controls">
              <input type="email" id="email" required name="email" placeholder="your email address?">
            </div>
          </div>

          <div class="control-group">
            <label class="control-label" for="inputPassword">Password</label>
            <div class="controls">
              <input id="inputPassword" required name="password" type="password"  placeholder="Password">
            </div>
          </div>
      </div>
      <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <button type="submit" class="btn btn-primary">Log in</button>
      </div>
    </div>


  </body>
</html>
